/*
	Copyright (C) 2009 jungil Han <jungil.Han@gmail.com>

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __MKBUTTON_H__
#define __MKBUTTON_H__

#include "../mkBase.h"
#include "../Animation/mkAnimation.h"

#include <QPushButton>

class mkButton : public QPushButton {
public:
	mkButton( QWidget *a_pParent = 0 );
	virtual ~mkButton();
	
	void SetBGImage( IN QString a_strDefaultImage, IN QString a_strOverImage, IN QString a_strClickImage );
	void SetFGImage( IN QString a_strDefaultImage, IN QString a_strOverImage, IN QString a_strClickImage, IN QRect *a_pRectangle = NULL);

	void SetBGImage( IN QImage &a_rDefaultImage, IN QImage &a_rOverImage, IN QImage &a_rClickImage );
	void SetFGImage( IN QImage &a_rDefaultImage, IN QImage &a_rOverImage, IN QImage &a_rClickImage, IN QRect *a_pRectangle = NULL);
		
	QString GetText();
	void SetText( IN QString a_strText, QRect *a_pRectangle, int a_nFontSize = 10, Qt::AlignmentFlag a_eAlignment = Qt::AlignHCenter);
	
	void SetAnimation( IN bool a_bAnimation = true );
	void SetAnimationTick( IN int a_nMilliSec );
	void SetMaximumAnimationSize( IN QSize *a_pMaxSize );

protected:
	virtual void paintEvent( IN QPaintEvent *a_pEvent );
	virtual void enterEvent( IN QEvent *a_pEvent );
	virtual void leaveEvent( IN QEvent *a_pEvent );

	/* for child class */
	virtual void OnPaint( IN QPainter *a_pPainter ) { }
	virtual void OnEnter( IN QEvent *a_pPainter ) { }
	virtual void OnLeave( IN QEvent *a_pPainter ) { }

private:	
	QImage *m_pDefaultBGImage;
	QImage *m_pOverBGImage;
	QImage *m_pClickBGImage;

	QImage *m_pDefaultFGImage;
	QImage *m_pOverFGImage;
	QImage *m_pClickFGImage;

	QRect *m_pFGRectangle;
	QRect *m_pFontRectange;

	QString m_strText;
	int m_nFontSize;
	Qt::AlignmentFlag m_eTextAlignment;
	
	bool m_bIsMouseOver;

	bool m_bHasEffect;
	mkAnimation *m_pAnimation;
};

#endif // __MKBUTTON_H__
